<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
    <button @click="run">点我-run</button>
    <child></child>
</div>
</body>
<script>
    Vue.prototype.$bus = new Vue();
    new Vue({
        el: "#root",
        methods:{
            run(){
                this.$bus.$emit("one",1,2,3,4)
            }
        },
        components: {
            Child: {
                data(){
                    return {
                        num:100
                    }
                },
                template: (`
                    <div>
                        <button @click="fn">点我</button>
                        <hr/>
                        <two></two>
                    </div>

				`),
                methods:{
                    fn(){
                        this.$bus.$emit("one",100,200,300,400)
                    }
                },
                mounted(){
                    this.$bus.$on("one",function(a,b,c,d){
                        console.log("one",a,b,c,d,this===this.$bus,this.num);
                    }.bind(this))
                },
                components:{
                    Two:{
                        template:(`
						    <button @click="$bus.$emit('one',10,20,30,40)">two</button>
						`)
                    }
                }
            }
        }
    })
</script>
</html>